<template>
  <div id="table_list" v-if="data_table">
    <ol class="flex_between flex_nav">
      <li :style="{width:100/data_table.attr.length+'%'}" v-for="(item,index) in data_table.nav"
          :key="index" :class="item.type?'special':''">{{item.name}}
        <i @click="showInfo(index,item.typeBox)" v-show="item.type"
           :class="item.typeBox?'iconfont active':'iconfont active deg90'">&#xe62a;</i>
        <div v-if="item.typeBox" class="prize_box">
          <div v-if="item.type&&item.type.length>0" v-for="(list,index2) in item.type" :key="index2"
               @click="getType(list,index)" class="prize_item" :class="currentId===list.id?'active':''">
            {{list.name}}
          </div>
        </div>
      </li>
      <li v-if="!data_table">游戏场次</li>
      <li v-if="!data_table">中奖人</li>
      <li v-if="!data_table">中奖时间</li>
    </ol>
    <ul class="table_ul" v-if="data_table.list&&data_table.list.length>0">
      <li v-for="(item,index) in data_table.list" :key="index" class="flex_between table_li">
        <span :style="{width:100/data_table.attr.length+'%'}" v-for="(v,i) in data_table.attr"
              :key="i">{{item[v]}}<i v-if="v==='operate'">{{item.amount}}</i><i
          v-if="v==='dividend'">{{item.coinType}}</i></span>

      </li>
      <!--<li class="flex_between table_li">-->
      <!--<span class="title">0.1ETH/第2期</span>-->
      <!--<span>开水白面包</span>-->
      <!--<span>11/02 23:24</span>-->
      <!--</li>-->
      <!--<li class="flex_between table_li">-->
      <!--<span class="title">0.1ETH/第2期</span>-->
      <!--<span>开水白面包</span>-->
      <!--<span>11/02 23:24</span>-->
      <!--</li>-->
    </ul>
    <van-pagination
      class="page_list"
      id="page_list"
      prev-text="<"
      next-text=">"
      v-model="currentPage"
      :total-items="total"
      :items-per-page="currentSize"
      @change="pageChange"
      force-ellipses
    />
  </div>
</template>

<script>
  export default {
    name: 'table_list',
    data() {
      return {
        prize_box: false,
        currentPage: 1,
        total: 0,
        currentSize: 10,
        currentId: 0
      }
    },
    props: ['data_table', 'totalCount', 'pageSize', 'pageNum'],
    methods: {
      showInfo(index, data) {
        this.data_table.nav[index].typeBox = !data
      },
      getType(list, index) {
        this.currentId = list.id
        this.$emit('typeData', list)
        this.data_table.nav[index].typeBox = !this.data_table.nav[index].typeBox
        this.$emit('handleType', list)
      },
      pageChange(page) {
        this.$emit('changePage', page)
      }
    },
    mounted() {
      console.log(this.totalCount)
      this.currentPage = Number(this.pageNum)
      this.total = Number(this.totalCount)
      this.currentSize = Number(this.pageSize)
    }
  }
</script>

<style lang="less">
  #table_list {
    margin: 0 24px;
    background: #1E3054;
    overflow: hidden;
    .flex_nav {
      position: relative;
      .active {
        color: #F1D487 !important;
      }
      .special{
        padding-left: 24px;
        box-sizing: border-box;
      }
      li {
        text-align: center;
        position: relative;
        &:nth-child(1) {
          text-align: left;
        }
        &:last-child {
          text-align: right;
        }
        > i {
          font-size: 32px;
          transition: all 0.3s;
          display: inline-block;
          position: relative;
          top: 4px;
          transform: rotate(180deg);
        }
        .deg90 {
          transform: rotate(0deg);
          top: -2px;
        }
        .prize_box {
          width: 700px;
          left: 0px;
          top: 86px;
          position: absolute;
          background: #283B62;
          color: #FFF;
          .prize_item {
            font-size: 26px;
            padding: 20px;
            line-height: 37px;
            text-align: left;
          }
        }
      }
    }
    .van-pagination__item {
      background: none;
      line-height: 44px;
      color: #fff;
      min-width: 70px;
      font-size: 22px;
    }
    .van-pagination__item::after {
      border: none;
    }
    #page_list {
      padding-top: 30px;
      line-height: 40px;
      .van-pagination__item--active {
        line-height: 44px;
        background: #F1D487;
        min-width: 44px;
        width: 44px;
        height: 44px;
        border-radius: 22px;
        padding: 0
      }
      /*.van-pagination__item--disabled, .van-pagination__item--disabled:active{background:none;}*/
      li {
        .van-pagination__prev {
          padding: 0 8px;
        }
      }
    }
    .flex_between {
      display: flex;
    }
    ol {
      li {
        font-size: 26px;
        color: #9F9F9F;
        position: relative;
        line-height: 37px;
        padding: 24px 0;
      }
      margin: 0 32px;
      border-bottom: 2px solid #F1D487;
      box-sizing: border-box;
    }
    .table_ul {
      margin: 0 32px;
      .table_li {
        border-bottom: 2px solid #F1D487;
        line-height: 37px;
        padding: 20px 0;
        font-size: 26px;
        color: #FFFFFF;
        .title {
          color: #F1D487;
        }
        > span {
          text-align: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          &:nth-child(1) {
            text-align: left;
          }
          &:last-child {
            text-align: right;
          }
        }
      }
    }
  }
</style>
